﻿using System;

namespace QuickMenus
{
    /// <summary>
    /// The top level entity that can exist in a menu. In principal, a MenuItem is either a sub-menu or an action that is made available via the menu.
    /// </summary>
    public abstract class MenuItem
    {
        /// <summary>
        /// The text that will be displayed by the <seealso cref="Menu"/> rendering this item.
        /// </summary>
        /// <returns></returns>
        public string DisplayName { get; set; }

        /// <summary>
        /// The task that should be executed when this item is selected by an end user.
        /// </summary>
        /// <returns>A task to be executed. It behaves as a typical console application, taking a series of arguments, and returning an error code.</returns>
        public abstract Func<string[], int> Operation { get; }

        /// <summary>
        /// Constructs a trivial MenuItem, merely initializing values.
        /// </summary>
        /// <param name="name">The text that should be displayed to identify this <see cref="MenuItem"/></param>
        public MenuItem(string name)
        {
            DisplayName = name;
        }
    }
}
